//
//  HomeViewController.m
//  WheatPlan
//
//  Created by giantumbrella on 15/5/21.
//  Copyright (c) 2015年 IOSTeam. All rights reserved.
//

#import "HomeViewController.h"
#import "CommonMacro.h"
#import "SDCycleScrollView.h"
#import "HomeStatisticViewController.h"
#import "SetOutViewController.h"
#import "DoorViewController.h"
#import "EvaluateViewController.h"
#import "myTabBarViewController.h"
#import "EvaluationViewController.h"
#import "MyFamilyViewController.h"
#import "MyFamilyTroViewController.h"
#import "LoginViewController.h"
#import "AddBabyViewController.h"
#import "EventViewController.h"
#import "WebViewController.h"

//#import "NewFileViewController.h"
#import "GetFileModel.h"
#define SCREEN_WIDTH                    ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT                   ([UIScreen mainScreen].bounds.size.height)
@interface HomeViewController ()<SDCycleScrollViewDelegate>{
    
    NSArray *myHomeImgarray;
    UIImageView * image2;
    UIWebView *webView;
}

@end

@implementation HomeViewController


-(void)viewDidAppear:(BOOL)animated{
    
    
    self.tabBarController.tabBar.selectedImageTintColor = [GetFileModel colorWithHexString:@"#ff763a" alpha:1];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    ////NSLog(@"%@真的很重要",self.type);
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *ID = [user objectForKey:@"ID"];
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];

    
    ////NSLog(@"%@啊哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈",ID);
    
    NSDictionary *param77 = @{@"userId": @"6666"};
    
    [UserDAL getFirstImgWithParams:param77 withBlock:^(NSArray *data, NSError *error) {
        if (data) {
                myHomeImgarray = data;

            
        if (myHomeImgarray.count!=0) {
            
                ////NSLog(@"首页的图片数组为%@",myHomeImgarray);
                ////NSLog(@"第一张的图片数组为%@",myHomeImgarray[0][@"bannerImageUrl"]);
                ////NSLog(@"第一张的图片数组为1111111");

            
        }else{
            
            
            [JKAlert showMessage:@"提示" message:@"暂无图片数据"];
            
            
        }
            
            
        }else
        {
            
        }
        
        
    }];
    

    //设置导航栏头文字
    self.navigationItem.title = @"";
    UIImageView * imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"hightImage.png"]];
    imageView.frame = CGRectMake((SCREEN_WIDTH-88)/2, (NavbarHight-22)/2-11, 88, 22);
    [self.navigationController.navigationBar addSubview:imageView];
    
    babyIDD = [NSMutableArray array];
    babyname = [NSMutableArray array];

    //设置导航栏背景颜色
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#ff763a" alpha:1]];
    //设置导航栏字体颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
    
    
//    NSUserDefaults *user6 = [NSUserDefaults standardUserDefaults];
//    NSString *userIds = [user6 objectForKey:@"userId"];
//    
//    NSUserDefaults *user7= [NSUserDefaults standardUserDefaults];
//    NSString *userCodes = [user7 objectForKey:@"userCode"];


    
    [self.tabBarController setDelegate:self];

    
    
    [self SDCycleScrollView];
    [self initSubViews];
    

    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];

    
    if (!userCode) {
        
        ////NSLog(@"我是空的");
        UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc]
                                     initWithTitle:@"登录"
                                     style:UIBarButtonItemStylePlain
                                     target:self
                                     action:@selector(turntoBaby)];
        [rightBtn setTintColor:[UIColor whiteColor]];
        self.navigationItem.rightBarButtonItem = rightBtn;
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            ////NSLog(@"%@wojiushizhidao",user.parentSchoolId);
            
            [BabyManager shareInstance].parentSchoolId = user.parentSchoolId;

            
//            
            
            if (babyID.count == 0) {
                
                
                
            }else{
                
                for (NSDictionary * dic in babyID) {
                    
                    NSString *babyID = [dic objectForKey:@"ID"];
                    [babyIDD addObject:babyID];
                    
                    NSString *babyName = [dic objectForKey:@"babyName"];
                    [babyname addObject:babyName];

                    
                }
                
                NSUserDefaults *user5 = [NSUserDefaults standardUserDefaults];
                NSString *babyAid = [user5 objectForKey:@"babyAid"];
                
                
                if (babyAid == nil) {
                    
                    [BabyManager shareInstance].babyId = babyIDD[0];

                    
                    
                    ////NSLog(@"%@",[BabyManager shareInstance].babyId);
                    
                }else{
                    
                    
                    [BabyManager shareInstance].babyId = babyAid;
                    ////NSLog(@"%@",[BabyManager shareInstance].babyId);

                    ////NSLog(@"222222");
                    
                }
                
                
                
                
                NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
                NSString *babyNameD = [user1 objectForKey:@"babyName"];

                if (babyNameD == nil) {
                    
                    [BabyManager shareInstance].homeName = babyname[0];
                    ////NSLog(@"我的名字%@",[BabyManager shareInstance].homeName);

                    
                }else{
                    

                    [BabyManager shareInstance].homeName = babyNameD;

                    ////NSLog(@"我的名字%@",[BabyManager shareInstance].homeName);

                    
                }

                ////NSLog(@"哦也哦也哦也");
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
            
        }];

        
        
        
        
        
        
    }
    
    


    NSUserDefaults *user3 = [NSUserDefaults standardUserDefaults];
    NSString *show = [user3 objectForKey:@"ID"];
    
    if (show) {
        
        //NSLog(@"111");
        
        [self  showMessage:@"感谢您的参与，您将开启观察和读懂、科学养育孩子的新历程！"];

        
    } else {
        
        //NSLog(@"222");
        
    }

    

    

}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
//
    
//    NSString *userId = @"";
//    NSString *userCode = @"";

    if ([viewController.title  isEqual: @"我家"]) {
        
        ////NSLog(@"bengbengbeng");
        
        if (!userCode) {
            
            ////NSLog(@"我是空的");
            
            LoginViewController * myTableView = [[LoginViewController alloc]init];
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
            [self  presentViewController:nav animated:YES completion:nil];
            
            
            [self.tabBarController setSelectedIndex:0];
            
            
        } else {
            
            
//            ////NSLog(@"你才是空的");
            NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
            [UserDAL getUser:param9 success:^(UserModel *user) {
                
                
                NSArray * babyID =  user.dataList;
                
                
                
                
                
                if (!babyID.count == 0) {
                    
                    
                    [self.tabBarController setSelectedIndex:4];
                    
                    
                    
                }else{
                    
                    
                    
                    
                    
                }
                
                
                
            } failed:^(NSError *error) {
                
                
                
                
            }];
            
            
        }

        
        
        
    }else{
        
        if (!userCode) {
            
            ////NSLog(@"我是空的");
            
            LoginViewController * myTableView = [[LoginViewController alloc]init];
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
            [self  presentViewController:nav animated:YES completion:nil];
            
            
            [self.tabBarController setSelectedIndex:0];
            
            
        } else {
            
            
            ////NSLog(@"你才是空的");
            NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
            [UserDAL getUser:param9 success:^(UserModel *user) {
                
                
                NSArray * babyID =  user.dataList;
                
                
                
                if (babyID.count == 0) {
                    
                    
                    UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                    
                    [alertview show];
                    
                    
                    [self.tabBarController setSelectedIndex:0];
                    
                    
                }else{
                    

                    ////NSLog(@"哦也哦也哦也");
                    
                    
                }
                
                
                
            } failed:^(NSError *error) {
                

                
                
            }];
            
            
        }

        
        
    }
    
    
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{
    
    NSString *msg = [[NSString alloc] initWithFormat:@"您点击的是第%d个按钮!",buttonIndex];
    
    ////NSLog(@"msg:%@",msg);
    
    
    
    if (buttonIndex == 0) {
        
        ////NSLog(@"1111111");
        
        
    }else if(buttonIndex == 1){
        
        
        AddBabyViewController * addView = [[AddBabyViewController alloc]init];
        addView.myBabyId = @"0";
        addView.gender = @"3";
        addView.city = @"1";
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:addView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        ////NSLog(@"2222222");

        
    }
    
}



-(void)turntoBaby{
    
    

    LoginViewController * myTableView = [[LoginViewController alloc]init];
    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
    [self  presentViewController:nav animated:YES completion:nil];

    
    
    
    
}
-(void)initSubViews{
    

    [MBProgressHUD hideHUDForView:self.view animated:YES];

    
    UIButton * thedoorButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self setbut:thedoorButton imageBtn:@"gexing.png"];
    [thedoorButton addTarget:self action:@selector(shangmen) forControlEvents:UIControlEventTouchUpInside];

    UIButton * integrationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [integrationButton addTarget:self action:@selector(gotoView) forControlEvents:UIControlEventTouchUpInside];
    [self setbut:integrationButton imageBtn:@"jiayuantonghe.png"];

    UIButton * cityButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self setbut:cityButton imageBtn:@"qinzi.png"];
    [cityButton addTarget:self action:@selector(qinzi) forControlEvents:UIControlEventTouchUpInside];

    UIButton * personalityButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self setbut:personalityButton imageBtn:@"shangmen.png"];
    [personalityButton addTarget:self action:@selector(gexing) forControlEvents:UIControlEventTouchUpInside];

    UIButton * activityButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self setbut:activityButton imageBtn:@"huodong.png"];
    [activityButton addTarget:self action:@selector(huodong) forControlEvents:UIControlEventTouchUpInside];

    
    
    

    if (IS_IPHONE_4_OR_LESS) {
        
        thedoorButton.frame = CGRectMake(10, SCREEN_HEIGHT/3+35, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2);
        integrationButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+35, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        cityButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+40+SCREEN_HEIGHT/3.2/2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        activityButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+45+SCREEN_HEIGHT/3.2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        personalityButton.frame = CGRectMake(10, SCREEN_HEIGHT/3+45+SCREEN_HEIGHT/3.2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);

    }else{
        
        thedoorButton.frame = CGRectMake(10, SCREEN_HEIGHT/3+40, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2);
        integrationButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+40, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        cityButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+45+SCREEN_HEIGHT/3.2/2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        activityButton.frame = CGRectMake(10+(SCREEN_WIDTH-30)/2+10, SCREEN_HEIGHT/3+55+SCREEN_HEIGHT/3.2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        personalityButton.frame = CGRectMake(10, SCREEN_HEIGHT/3+55+SCREEN_HEIGHT/3.2, (SCREEN_WIDTH-30)/2, SCREEN_HEIGHT/3.2/2-5);
        
    }
    
    
    
}

-(void)gotoView{
    
    
    ////NSLog(@"111");
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
    
    
    
    
    if (!userCode) {
        

        
        
        ////NSLog(@"我是空的");

        LoginViewController * myTableView = [[LoginViewController alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        
        
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            
            
            
            if (babyID.count == 0) {
                
                
                UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                
                [alertview show];

                
            }else{
                
                HomeStatisticViewController *homeStaView = [[HomeStatisticViewController alloc]init];
                UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:homeStaView];
                [self  presentViewController:nav animated:YES completion:nil];
                
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
        }];
        

        
    }
    

    
    
    
    
    
    
    
}
-(void)gexing{
    
    
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
    
    
    
    

    
    if (!userCode) {
        
        
        
        
        ////NSLog(@"我是空的");
        
        LoginViewController * myTableView = [[LoginViewController alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        
        
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            
            
            
            if (babyID.count == 0) {
                
                UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                
                [alertview show];
                
                
                
            }else{
                
                
                [self.tabBarController setSelectedIndex:2];

                
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
            
            
            
            
            
            
            
        }];
        
        
        
        
        
        
        
    }
    
    
    

}
-(void)qinzi{
    
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
    
    
    
    
    
    if (!userCode) {
        
        
        
        
        ////NSLog(@"我是空的");
        
        LoginViewController * myTableView = [[LoginViewController alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        
        
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            
            
            
            if (babyID.count == 0) {
                
                UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                
                [alertview show];
                
                
                
            }else{
                
                [self.tabBarController setSelectedIndex:3];
                
                
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
            
            
            
            
            
            
            
        }];
        
        
        
        
        
        
        
    }
    

}
-(void)shangmen{
    
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
    
    
    
    
    
    if (!userCode) {
        
        
        
        
        ////NSLog(@"我是空的");
        
        LoginViewController * myTableView = [[LoginViewController alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        
        
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            
            
            
            if (babyID.count == 0) {
                
                UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                
                [alertview show];
                
                
                
            }else{

                [self.tabBarController setSelectedIndex:1];
                
                
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
            
            
            
            
            
            
            
        }];
        
        
        
        
        
        
        
    }
    

    
}
-(void)huodong{
    
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString *userId = [user1 objectForKey:@"userId"];
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString *userCode = [user2 objectForKey:@"userCode"];
    
    
    
    
    
    if (!userCode) {
        
        
        
        
        ////NSLog(@"我是空的");
        
        LoginViewController * myTableView = [[LoginViewController alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
        [self  presentViewController:nav animated:YES completion:nil];
        
        
        
    } else {
        
        
        ////NSLog(@"你才是空的");
        
        
        
        
        NSDictionary *param9 = @{@"userName":userId,@"password":userCode};
        [UserDAL getUser:param9 success:^(UserModel *user) {
            
            
            NSArray * babyID =  user.dataList;
            
            
            
            if (babyID.count == 0) {
                
                UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请您先添加宝宝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                
                [alertview show];
                
                
                
            }else{
                
                
                ////NSLog(@"%@",[BabyManager shareInstance].parentSchoolId);
                
                EventViewController * myTableView = [[EventViewController alloc]init];
                myTableView.activityId = [BabyManager shareInstance].parentSchoolId;
                UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
                [self  presentViewController:nav animated:YES completion:nil];
                
                
                
                
            }
            
            
            
        } failed:^(NSError *error) {
            
            
            
        }];
        
        
        
    }
    

    
    

    
    
    
    
    
}
#pragma mark - SDCycleScrollView

-(void)SDCycleScrollView{
    

    
    NSDictionary *param77 = @{@"userId": @"1"};
    
    [UserDAL getFirstImgWithParams:param77 withBlock:^(NSArray *data, NSError *error) {
        if (data) {
            
        myHomeImgarray = data;

            if (myHomeImgarray.count!=0) {
                
                NSMutableArray *imagesURL = [NSMutableArray array];
                
                for (NSDictionary *dic in myHomeImgarray) {
                    
                    NSURL *tmp = [NSURL URLWithString:dic[@"bannerImageUrl"]];
                    [imagesURL addObject:tmp];
                }
                

                self.view.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:0.99];
      
                SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, NavbarHight, SCREEN_WIDTH, SCREEN_HEIGHT/3-30) imageURLsGroup:imagesURL];
                cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
                cycleScrollView.delegate = self;
//                cycleScrollView.titlesGroup = titles;
                cycleScrollView.autoScrollTimeInterval = 2;
                [self.view addSubview:cycleScrollView];

                
                
                
                
                
                
            }
            
            
        }else
        {
            
        }
        
        
    }];
    
    
    
    
}


-(void)setbut:(UIButton *)button imageBtn:(NSString *)imageStr{
    
    

    [button setImage:[UIImage imageNamed:imageStr] forState:UIControlStateNormal];
    
    [self.view addSubview:button];
    
    
    
    
}


#pragma mark - SDCycleScrollViewDelegate

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    
    
    //    //NSLog(@"---点击了第%ld张图片", (long)index);
    
    
    NSDictionary *param77 = @{@"userId": @"6666"};
    
    [UserDAL getFirstImgWithParams:param77 withBlock:^(NSArray *data, NSError *error) {
        if (data) {
            //NSLog(@"woshi%@",myHomeImgarray[index][@"linkUrl"]);
            myHomeImgarray = data;
            
            if (![myHomeImgarray[index][@"linkUrl"]isEqualToString:@""]) {
                
                
                self.view.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:0.99];
                
                WebViewController * myTableView = [[WebViewController alloc]init];
                myTableView.webViewUrl = myHomeImgarray[index][@"linkUrl"];
                UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:myTableView];
                [self  presentViewController:nav animated:YES completion:nil];
                
            }
        }
        
    }];
    
    
}
- (void)showMessage:(NSString *)message {
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    
    UIView *showView =  [[UIView alloc]init];
    showView.backgroundColor = [UIColor blackColor];
    showView.frame = CGRectMake(1, 1, 1, 1);
    showView.alpha = 1.0f;
    showView.layer.cornerRadius = 5.0f;
    showView.layer.masksToBounds = YES;
    [window addSubview:showView];
    
    UILabel *label = [[UILabel alloc]init];
    CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
    
    label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
    label.text = message;
    label.textColor = [UIColor whiteColor];
    label.textAlignment = 1;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:15];
    label.numberOfLines = 0;
    [showView addSubview:label];
    showView.frame = CGRectMake((SCREEN_WIDTH - LabelSize.width - 20)/2, SCREEN_HEIGHT /2, LabelSize.width+20, LabelSize.height+10);
    [UIView animateWithDuration:5 animations:^{
        showView.alpha = 0;
    } completion:^(BOOL finished) {
        [showView removeFromSuperview];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
